package com.azxcrm.project.system.customer.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.azxcrm.common.utils.StringUtils;
import com.azxcrm.common.utils.security.ShiroUtils;
import com.azxcrm.project.system.customer.dao.ICustomerAttendanceDao;
import com.azxcrm.project.system.customer.domain.CustomerAttendance;

/**
 * 客户参课列 服务层实现
 * 
 * @author Dustyone
 * @date 2018-08-28
 */
@Service
public class CustomerAttendanceServiceImpl implements ICustomerAttendanceService 
{
	@Autowired
	private ICustomerAttendanceDao customerAttendanceDao;
	
	/**
     * 查询客户参课列信息
     * 
     * @param attendId 客户参课列ID
     * @return 客户参课列信息
     */
	 @Override
	public CustomerAttendance selectCustomerAttendanceById(Integer attendId)
	{
	    return customerAttendanceDao.selectCustomerAttendanceById(attendId);
	}
	
	/**
     * 查询客户参课列列表
     * 
     * @param customerAttendance 客户参课列信息
     * @return 客户参课列集合
     */
	 @Override
	public List<CustomerAttendance> selectCustomerAttendanceList(CustomerAttendance customerAttendance)
	{
	    return customerAttendanceDao.selectCustomerAttendanceList(customerAttendance);
	}
	
    /**
     * 新增客户参课列
     * 
     * @param customerAttendance 客户参课列信息
     * @return 结果
     */
	 @Override
	public int insertCustomerAttendance(CustomerAttendance customerAttendance)
	{
	    return customerAttendanceDao.insertCustomerAttendance(customerAttendance);
	}
	
	/**
     * 修改客户参课列
     * 
     * @param customerAttendance 客户参课列信息
     * @return 结果
     */
	 @Override
	public int updateCustomerAttendance(CustomerAttendance customerAttendance)
	{
	    return customerAttendanceDao.updateCustomerAttendance(customerAttendance);
	}
	
	/**
     * 保存客户参课列
     * 
     * @param customerAttendance 客户参课列信息
     * @return 结果
     */
	 @Override
	public int saveCustomerAttendance(CustomerAttendance customerAttendance)
	{
	    Integer attendId = customerAttendance.getAttendId();
		int rows = 0;
		if (StringUtils.isNotNull(attendId))
        {
		    rows = customerAttendanceDao.updateCustomerAttendance(customerAttendance);
		}
		else
        {
			customerAttendance.setCreateBy(ShiroUtils.getLoginName());
		    rows = customerAttendanceDao.insertCustomerAttendance(customerAttendance);
		}
		return rows;
	}
	
	/**
     * 删除客户参课列信息
     * 
     * @param attendId 客户参课列ID
     * @return 结果
     */
	 @Override
	public int deleteCustomerAttendanceById(Integer attendId)
	{
	    return customerAttendanceDao.deleteCustomerAttendanceById(attendId);
	}
	
	/**
     * 批量删除客户参课列对象
     * 
     * @param attendIds 需要删除的数据ID
     * @return 结果
     */
	 @Override
	public int batchDeleteCustomerAttendance(Integer[] attendIds)
	{
		return customerAttendanceDao.batchDeleteCustomerAttendance(attendIds);
	}

	 /**
	 * 查询参课列对象
	 * 
	 * @param attendIds 客户参课列手机号
	 * @return 客户参课列集合
	 */
	@Override
	public List<CustomerAttendance> selectCustomerAttendanceByCellphone(String cellphoneNum) {
		return customerAttendanceDao.selectCustomerAttendanceByCellphone(cellphoneNum);
	}

	/**
     * 查询客户参课列信息取最新
     * 
     * @param customerAttendance 客户参课对象
     * @return 客户参课列信息
     */
	@Override
	public CustomerAttendance selectCustomerAttendanceNewest(CustomerAttendance customerAttendance) {
		return customerAttendanceDao.selectCustomerAttendanceNewest(customerAttendance);
	}
	
}
